import jaydebeapi
# 导入所需的 模块与包
import jpype
import  os
# 导入所需的 模块与包
import jpype

#自动获取虚拟机路径
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=%s" % "mysql-connector-java-5.1.49.jar")
# 自动获取虚拟机路径
# 配置
# urlconfig = {
#     'jkurl': 'http://172.20.46.134:8085/thredds/catalog/testAll/',
#     'localdirpath':'/qixiang/qxwj/'
# }
urlconfig = {
    'jkurl': 'http://111.198.60.33:9093/history_data/',
    'localdirpath': 'Y:/python_projects/dlqx/update/'
}
# 数据库配置
databases1 = {
    'jclassname': 'com.mysql.jdbc.Driver',
    'url': 'jdbc:mysql://111.198.60.33:13306/dl_06?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT&useSSL=false',
    'driver_args': ['root', '123456'],
    'jars': 'mysql-connector-java-5.1.49.jar'
}
databases2 = {
    'jclassname': 'com.mysql.jdbc.Driver',
    'url': 'jdbc:mysql://111.198.60.33:13306/dl_07?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT&useSSL=false',
    'driver_args': ['root', '123456'],
    'jars': 'mysql-connector-java-5.1.49.jar'
}
databases3 = {
    'jclassname': 'com.mysql.jdbc.Driver',
    'url': 'jdbc:mysql://111.198.60.33:13306/dl_08?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT&useSSL=false',
    'driver_args': ['root', '123456'],
    'jars': 'mysql-connector-java-5.1.49.jar'
}

def tosql3():
    a = os.getcwd()
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    conn3 = jaydebeapi.connect(databases3["jclassname"], databases3["url"], databases3["driver_args"],
                               databases3["jars"])
    cursor3 = conn3.cursor()
    os.chdir(a)
    return [conn3, cursor3]

# if __name__ == '__main__':
#     sql = "SELECT * FROM tb_qxsj"
#     c1 = tosql3()
#     c1[1].execute(sql)
#     qxsj = c1[1].fetchall()